import request from '@/utils/request';
import da from "element-ui/src/locale/lang/da";

// 获取图件审查列表
export function getDrawingAuditAdviceList(data) {
  return request({
    url: '/renovation/drawingAuditAdvice/list',
    method: 'post',
    json: data
  })
}

// 获取前期测绘综合监管
export function getSuperviceList(data) {
  return request({
    url: `/renovation/planningBudget/supervising_info`,
    method: 'post',
    json: data
  })
}

// 添加图件审查意见
export function addDrawingAuditAdviceList(data) {
  return request({
    url: `/renovation/drawingAuditAdvice/save`,
    method: 'post',
    json: data
  })
}

// 获取文件详情列表
export function getFileDetail(projectId) {
  return request({
    url: `/renovation/planningBudget/resultFile/list?projectId=${projectId}`,
    method: 'post'
  })
}

// 修改图件审查意见
export function updateDrawingAuditAdvice (data) {
  return request({
    url: `/renovation/drawingAuditAdvice/update`,
    method: 'post',
    json: data
  })
}

// 修改图件审查意见
export function delDrawingAuditAdvice (id) {
  return request({
    url: `/renovation/drawingAuditAdvice/delete?id=${id}`,
    method: 'post'
  })
}

// 导出图件审查意见
export function exportDrawingOpinions(data) {
  const url = makeQueryToPrams('/renovation/drawingAuditAdvice/export', data)
  return request({
    url: url,
    method: 'get',
    responseType:'blob'
  })
}

// 导出附件审查意见
export function exportAnnexOpinions(data) {
  return request({
    url: '/renovation/attachmentAuditAdvice/export',
    method: 'post',
    responseType:'blob',
    formData: data
  })
}

//校验审查意见
export function recheckReviewOpinion(data) {
  return request({
    url:"/renovation/planningBudget/auditAdvice/dist/save",
    method:"post",
    formData:data
  })
}

//入库资料校验审查意见
export function docCheckReviewOpinion(data) {
  return request({
    url:"/renovation/planningBudget/auditAdvice/municipal/save",
    method:"post",
    formData:data
  })
}


// 处理参数为url query方式
function makeQueryToPrams(url, data) {
  let link = url
  if(link.indexOf('?') == -1) {
    link += '?'
  }
  for (let i in data) {
    link += i + '=' + data[i] + '&'
  }
  return link
}
